#ifndef __OGLWINDOW_H__
#define __OGLWINDOW_H__

/*
	OGLWINDOW.H

	COGLWindow class

	OpenGL Game Programming
	Author: Kevin Hawkins
	Date: 3/19/2001
	Description: The COGLWindow class handles Windows messages and
			   distributes the messages among the engine.

*/

/*#include <windows.h>*/
#include <SDL/SDL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>

#include "InputSystem.h"

class COGLWindow
{
protected:
	SDL_Surface *screen;
	int flags;

	virtual bool OnCreate() { return true; }
	virtual bool OnClose() { return true; }
	virtual void OnSize() { }
	virtual void OnMouseDownL(float x, float y) { }
	virtual void OnMouseDownR(float x, float y) { }
	virtual void OnMouseUpL() { }
	virtual void OnMouseUpR() { }
	virtual void OnMouseMove(int x, int y, int centerX, int centerY) { }
	virtual void OnMouseMove(int deltaX, int deltaY) { }
	virtual void OnMouseDragL(int x, int y, int dx, int dy) { }
	virtual void OnMouseDragR(int x, int y, int dx, int dy) { }
	virtual void OnKeyUp(SDLKey nVirtKey) { }
	virtual void OnKeyDown(SDLKey nVirtKey) { }
	virtual void OnChar(char c) { }

	int WndProcOGL(SDL_Event event);
/*	
 	HWND		hWnd;	// window handle
	HDC		hDC;		// device context
	HPALETTE	hPalette;	// palette
	HGLRC	hGLRC;	// rendering context
	virtual void OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtrl) { }
	virtual void OnContextMenu(HWND hWnd, int x, int y) { } 
	virtual void OnInitMenu(HMENU hMenu) { }
*/

private:
	// message handling functions
	void Destroy();				   
	void Size();					
	void MouseMove(int x, int y);	

	float GetNormalizedPosX(int x);	// get normalized mouse coordinates
	float GetNormalizedPosY(int y);	// between (-1.0 and 1.0)

	void BeginFullScreen(int w, int h, int b);
	void EndFullScreen();

/*	
 	// the WndProc
	friend LRESULT APIENTRY WndProcOGL(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	void SetupPixelFormat();		// setup the pixel format
	void SetupPalette();		// setup the palette
	bool Create();					// WM_CREATE 
	void PaletteChanged(WPARAM wParam);// WM_PALETTECHANGED
	BOOL QueryNewPalette();			// WM_QUERYNEWPALETTE 
	void Paint();					// WM_PAINT 
	int iPrevWidth;
	int iPrevHeight;
	int GetMouseX(SDL_Event mEvent);	// get true mouse coordinates
	int GetMouseY(SDL_Event mEvent);
*/

public:
	int width;
	int height;
	int centerX;
	int centerY;
	int bits;
	int aspect;
	int mouseX;
	int mouseY;
	bool fullscreen;

	float mouseSensitivity;

	bool useInput;
	CInputSystem *inputSystem;

	COGLWindow() {}
	COGLWindow(const char *szName, bool fscreen, int w, int h, int b);
	virtual ~COGLWindow();

	// this must be called before the class is used
/*	static bool RegisterWindow(HINSTANCE hInst);*/
};

#endif
